package com.netsdk.entity;

import java.util.HashMap;
import java.util.Map;

public class R extends HashMap<String, Object> {
	private static final String MSG = "message";
	private static final String CODE = "retCode";

	public R() {
		put(CODE, "0000");
		put(MSG, "操作成功");
	}

	public static R error() {
		return error("1000", "参数错误");
	}

	// 其他错误
	public static R error(String msg) {
		return error("9999", msg);
	}

	public static R error(String code, String msg) {
		R r = new R();
		r.put(CODE, code);
		r.put(MSG, msg);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.put(MSG, msg);
		return r;
	}

	public static R ok(Map<String, Object> map) {
		R r = new R();
		r.putAll(map);
		return r;
	}

	public static R ok() {
		return new R();
	}

	@Override
	public R put(String key, Object value) {
		super.put(key, value);
		return this;
	}
}
